package com.shibo.product.controller;

import com.shibo.product.entity.Product;
import com.shibo.product.service.ProductService;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//@RequestMapping("/api/product")
@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    //查询商品
    @GetMapping("/product/{id}")
    public Product getProduct(@PathVariable("id") Long productId,
                              HttpServletRequest request){

        String header = request.getHeader("X-Token");
        System.out.println("X-Token:【"+header + "】");
        Product product = productService.getProductById(productId);
        return product;

    }


}
